<?php

if (!defined('BASEPATH')) exit('No direct script access allowed');

class Payment_mod extends CI_Model
{   
    
    private $_dbTableBilling = 'billing';
    private $_dbTableUsers = 'users';
   /**
     *  class sonstructor
     */
    function __construct() 
	{
		// Call the Model constructor
        parent::__construct();
	}
        
     public function check_txnid($txn_id){
         $sql = "SELECT {$this->_dbTableBilling}.transaction_id
                FROM  {$this->_dbTableBilling}
                WHERE {$this->_dbTableBilling}.transaction_id ='{$txn_id}' ";
        $query = $this->db->query($sql);
        
        //echo $this->db->last_query();
        $errors = $this->db->_error_message();
        if (!empty($errors)) {
          throw new Exception("SQL Error: " . $errors);
        } else { }

        if ($query->num_rows() > 0) {
          return false;
        } else {
          return true;
        }
     }
     public function check_price($payment_amount, $item_name){
         if($payment_amount==$this->config->item($item_name))
             return true;
         else            
             return false;
     }
     public function updatePayments($data){
         
        $this->db->insert($this->_dbTableBilling,$data);
       //echo $this->db->last_query();
        $errors = $this->db->_error_message();
        if (!empty($errors)) {
          throw new Exception("SQL Error: " . $errors);
          return false;
        } else {
            return true; //$this->db->insert_id();
        }
        
       return true;
     }
}
?>
